Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add siwe auth endpoints #177

Merged
merged 4 commits into from
Jun 25, 2024
Merged

feat: Add siwe auth endpoints #177

merged 4 commits into from
Jun 25, 2024

Conversation

usame-algan
Copy link
Member

@usame-algan usame-algan commented Jun 24, 2024

What it solves

  • Adds two new functions getAuthNonce and verifyAuth
  • Adds includeCredentials parameter to get/post/put/delete calls

How to test

  1. Checkout this branch locally and run yarn link
  2. Use the local package in feat: Add method to Sign in with Ethereum [SW-28] safe-wallet-web#3853
  3. Observe the sign in flow still works

@usame-algan usame-algan requested review from katspaugh and jmealy and removed request for katspaugh June 24, 2024 09:46
src/index.ts Outdated
{
body,
},
true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to make the credentials flag part of the endpoint type in api.ts.

src/index.ts Outdated
@@ -640,4 +641,15 @@ export function getContract(chainId: string, contractAddress: string): Promise<C
})
}

export function getAuthNonce(): Promise<AuthNonce> {
return getEndpoint(baseUrl, '/v1/auth/nonce', { credentials: 'include' }, undefined)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pass undefined explicitly?

Suggested change
return getEndpoint(baseUrl, '/v1/auth/nonce', { credentials: 'include' }, undefined)
return getEndpoint(baseUrl, '/v1/auth/nonce', { credentials: 'include' })

src/types/api.ts Outdated
post: operations['verify_auth']
parameters: {
path: null
credentials: RequestCredentials
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can only be include, right? The endpoint doesn't make sense w/ a different value.

Suggested change
credentials: RequestCredentials
credentials: 'include'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gut diese

@usame-algan usame-algan merged commit ab3419f into main Jun 25, 2024
4 checks passed
@usame-algan usame-algan deleted the siwe-auth branch June 25, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants